import random
num_final = random.randint(1, 5)
# 通过布尔变量 控制循环是否继续
flag=True
# 猜测总次数
count=0
while flag:
    num_guess=int(input("输入你猜测的数字："))
    count+=1
    if num_guess == num_final:
        print(f'猜对了,共猜了{count}次')
        flag=False
    else:
        if num_guess<num_final:
            print('猜小了')
        else:
            print('猜大了')

